<form class="layui-form" action="/article-class/edit">
    <div class="layui-form-item">
        <label class="layui-form-label">分类</label>
        <div class="layui-input-inline">
            <input type="text" name="article_class_name" value="" lay-verify="required" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">文章标题</label>
        <div class="layui-input-inline">
            <input type="text" name="title" value="" lay-verify="required" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">内容</label>
        <div class="layui-input-inline">
            <textarea class="layui-textarea" id="demo1" style="display: none"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">排序</label>
            <div class="layui-input-inline">
                <input type="text" name="sort" value="" lay-verify="required|number" class="layui-input"
                       placeholder="默认50，越大越靠前">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">是否显示</label>
        <div class="layui-input-block">
            <input type="checkbox" checked="" value="1" name="is_show" lay-skin="switch"
                   lay-text="ON|OFF">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <input type="hidden" name="<?= Yii::$app->request->csrfParam ?>"
                   value="<?= Yii::$app->request->csrfToken ?>">
            <input type="hidden" name="article_id" value="">
            <input type="button" class="layui-btn editForm" value="保存">
        </div>
    </div>
</form>
<script>
    layui.use(['layer', 'form', 'layedit'], function () {
        var layer = layui.layer,
            form = layui.form(),
            layedit = layui.layedit;
        //构建一个默认的编辑器
        layedit.build('demo1', {
            uploadImage: {url: '<?=HTTP_DOMAIN_ASSETS?>/up/image?path=article&source=layui', type: 'post'}
        });
        $('.editForm').click(function () {
            var formObj = $(this).closest('form');
            var url = formObj.attr('action');
            var data = formObj.serializeArray();
            var jsonObj = {};
            for (var i in data) {
                jsonObj[data[i].name] = data[i].value;
            }
            $.post(url, jsonObj, function (rs) {
                if (rs.code === 0) {
                    layer.msg(rs.msg);
                    setTimeout(function () {
                        window.location.href = rs.redirect;
                    }, 1000);
                } else {
                    layer.msg(rs.msg);
                }
            });
            return false;
        });
    });
</script>